<template>
<a :href="detailUrl">
  <div class="book-card">
    <div class="thumb"><img @click.stop="preview" :src="book.image" mode="aspectFill"></div>
    <div class="detail">
      <div class="row text-primary">
        <div class="title">{{book.title}}</div>
        <div>{{book.rate}}<Rate :value="book.rate"></Rate></div>
      </div>
      <div class="row">
        <div>{{book.author}}</div>
        <div>浏览量：{{book.count}}</div>
      </div>
      <div class="row">
        <div>{{book.publisher}}</div>
        <div>添加人:{{book.user_info ? book.user_info.nickName : ''}}</div>
      </div>
    </div>
  </div>
  </a>
</template>
<script>
import Rate from '@/components/Rate'
export default {
  props: ['book'],
  components: {
    Rate
  },
  computed: {
    detailUrl () {
      return '/pages/detail/main?id=' + this.book.id
    }
  },
  methods: {
    preview () {
      wx.previewImage({
        current: this.book.image,
        urls: [this.book.image]
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.book-card {
  padding: 20rpx;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  .thumb {
    width: 180rpx;
    height: 180rpx;
    img {
      width: 180rpx;
      height: 180rpx;
    }
  }
  .detail {
    width: 480rpx;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180rpx;
    div {
      font-size: 30rpx;
      &.title {
        width: 60%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
}
</style>


